﻿using System.Runtime;

namespace Admin.Crypto.Utils
{
    public class ResultOutput<TOut> 
    {
        public int Code { get; set; }
        public string Message { get; set; } = string.Empty;
        public TOut? Result { get; set; } = default;
    }

    public class ResultOutput : ResultOutput<object>
    { 
    
    }

    public static class ResultExtensions
    { 
        public static ResultOutput<TOut> Ok<TOut>(TOut data, int code = 200)
        {
            return new ResultOutput<TOut> { 
                Code = code,
                Message = string.Empty,
                Result = data
            };
        }

        public static ResultOutput<TOut> Fail<TOut>(int code, string message)
        {
            return new ResultOutput<TOut>
            {
                Code = code,
                Message = message
            };
        }
    }
}
